package cn.com.sparkle.paxos.util;

import java.util.zip.Adler32;

public class Adler32Calc {
	public static long calc(byte[] bytes, int off, int len) {
		Adler32 alder32 = new Adler32();
		alder32.update(bytes, off, len);
		return alder32.getValue();
	}

	public static long calc(byte[] bytes) {
		return calc(bytes, 0, bytes.length);
	}

	public static void main(String[] args) {
		long ct = System.currentTimeMillis();
		String a = "qinanffffffffffffffffffffffffwefwewiiiiiiiiiiiii4444444444999999999999999999999995888888888888885ffffffffffffffffffffwewwwwwwww";
		// a += a;
		// a += a;
		System.out.println(a.getBytes().length);
		for (int i = 0; i < 800000; ++i) {
			calc(a.getBytes());
		}
		System.out.println(System.currentTimeMillis() - ct);
	}
}
